<!--renshuai-->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="" prop="pdrName">
        <el-input
            v-model="queryParams.pdrName"
            placeholder="商家名称"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="transactionId">
        <el-input
            v-model="queryParams.transactionId"
            placeholder="支付交易单号"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="outTradeNo">
        <el-input
            v-model="queryParams.outTradeNo"
            placeholder="商户单号"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="payWay">
        <el-select v-model="queryParams.payWay" placeholder="付款渠道" clearable>
          <el-option  v-for="(item,index) in payWayList" :key="item.value" :label="item.label" :value="item.value"/>
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="tradeState">
        <el-select v-model="queryParams.tradeState" placeholder="交易状态" clearable>
          <el-option  v-for="(item,index) in tradeStateList" :key="item.value" :label="item.label" :value="item.value"/>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" width="50px" align="center">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="商家" align="center" prop="pdrName" :show-overflow-tooltip="true"/>
      <el-table-column label="支付渠道" align="center" prop="payWay" width="90">
        <template slot-scope="scope">
          <span v-for="(item,index) in payWayList" v-if="item.value==scope.row.payWay">{{item.label}}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付类型" align="center" prop="payType" width="90">
        <template slot-scope="scope">
          <span v-for="(item,index) in payTypeList" v-if="item.value==scope.row.payType">{{item.label}}</span>
        </template>
      </el-table-column>
      <el-table-column label="金额" align="center" prop="payAmount"/>
      <el-table-column label="商户订单号" align="center" prop="outTradeNo"/>
      <el-table-column label="支付订单号" align="center" prop="transactionId"/>
      <el-table-column label="交易状态" align="center" prop="tradeStateDesc"/>
      <el-table-column label="描述" align="center" prop="description"/>
      <el-table-column label="交易时间" align="center" prop="createTime" width="95">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-if="scope.row.tradeState=='SUCCESS'"
              type="text"
              size="small"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['']">退款</el-button>
        </template>
      </el-table-column>-->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改话框 -->
    <el-dialog :title="title" :visible.sync="open" width="780px" append-to-body center :before-close="handleClose">
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="onSubmitForm">保 存</el-button>
        <el-button @click="handleClose">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {getDocById, listDoc, updateDoc} from "@/api/cms/doc";
import {listPdrPayRecord} from "@/api/fin/pdrpay";

export default {
  name: "PdrRecordList",
  data() {
    return {
      payWayList:[
        {
          value:"WECHAT",
          label:"微信"
        },
        {
          value:"ALIPAY",
          label:"支付宝"
        }
      ],
      tradeStateList:[
        {
          value:"",
          label:"全部"
        },
        {
          value:"SUCCESS",
          label:"支付成功"
        },
      ],
      payTypeList:[
        {
          value:"RECHARGE",
          label:"充值"
        }
      ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //是否打开编辑
      openIsEdit:false,
      // 查询参数
      queryParams: {
        pdrName: undefined,
        transactionId:undefined,
        outTradeNo: undefined,
        payWay: undefined,
        tradeState:"SUCCESS",
        pageNum: 1,
        pageSize: 10
      },
      // 表单参数
      form: {
      },
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      listPdrPayRecord(this.queryParams).then(response => {
        this.dataList = response.data;
        this.total = Number(response.total);
        this.loading = false;
      });
    },

    // 表单重置
    reset() {
      this.form = {
        pkId: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },


  }
};
</script>
<style lang="scss" scoped>
</style>